package ants.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class AntsUtil {
	
	public static String DATE_FORMAT_STRING="yyyy-MM-dd hh:mm:ss";
	
	public static Map getPropertiesWithConfigProperty() throws IOException{
		return getProperties("src/config.properties");
	}
	
	private static Map getProperties(String filePath) throws IOException{
		Properties p=new Properties();
		Map result=new HashMap();
		File configProperty=new File(filePath);
		InputStream in=new FileInputStream(configProperty);
		p.load(in);
		Enumeration e=p.propertyNames();
		while(e.hasMoreElements()){
			String key=e.nextElement().toString();
			String value=p.getProperty(key);
			result.put(key, value);
		}
		in.close();
		return result;
	}
	
	
	public static void main(String[] args) throws IOException{
		getPropertiesWithConfigProperty();
	}
	
	public static String formatDate(Date date,String formatString){
        return new SimpleDateFormat(formatString).format(date);
	}
	
	
	
}
